<HTML><HEAD><TITLE>profile(+Goal, ++Flags)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Development Environment and Global Settings</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>profile(+Goal, ++Flags)</H1>
Profile the goal and print the times spent in each predicate.


<DL>
<DT><EM>Goal</EM></DT>
<DD>Atom or a compound term.
</DD>
<DT><EM>Flags</EM></DT>
<DD>List of atoms.
</DD>
</DL>
<H2>Description</H2>
<P>   This predicate invokes the profiler.  The profiler first executes Goal
   in profiling mode, which means that during its execution interrupts are
   generated at regular intervals and the profiler remembers the currently
   executing predicate.  When the goal succeeds or fails, the profiler
   prints so, and then it prints the statistics about the time spent in
   every encountered predicate.  Goal can be any Prolog goal, it does not
   have to be compiled in a special profiling mode and no Prolog flags have
   to be set.  The time spent in simple predicates (i.e. those with call_type
   external, written in C) is counted towards their parent predicate.
</P><P>
   In cases where the predicate name is not available, e.g. local goals in
   a locked module, the information is grouped under a blank predicate
   name entry for the module.
</P><P>
   Flags is a list of option flags:
   <DL>
   <DT>simple</DT>
       <DD>obsolete</DD>
   <DT>keep_file</DT>
       <DD>do not remove temporary data file when finished</DD>
   </DL>
</P><P>
   A temporary file &lt;tmp_dir&gt;/eclipse.prof.&lt;pid&gt; is used to collect the
   profiling information and is removed upon exit (unless keep_file option
   is given).
</P>

<H3>Modes and Determinism</H3><UL>
<LI>profile(+, ++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(6) out of range </EM>
<DD>Flags contains an illegal flag.
</DL>
<H2>Examples</H2>
<PRE>
[eclipse 6]: profile(boyer, []).
rewriting...
proving...
goal succeeded

                PROFILING STATISTICS
                --------------------

Goal:             boyer
Total user time:  10.55s

Predicate             Module         %Time  Time
-------------------------------------------------
=..               /2  sepia_kernel   31.1%  3.28s
garbage_collect   /0  sepia_kernel   23.5%  2.48s
rewrite           /2  eclipse        21.6%  2.28s
rewrite_args      /2  eclipse        17.2%  1.82s
equal             /2  eclipse         4.1%  0.43s
remainder         /3  eclipse         0.9%  0.10s
...
plus              /3  eclipse         0.1%  0.01s

yes.




</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/env/get_flag-2.html">get_flag / 2</A>, <A HREF="../../kernel/env/profile-1.html">profile / 1</A>
</BODY></HTML>
